System and method for use with garbage collected languages for enabling the allocated heap memory to be updated at runtime

ABSTRACT

A system and method for use with garbage collected systems and languages, for enabling an allocated heap memory to be updated (e.g., increased or decreased) at runtime, subject to sufficient availability of physical memory. In accordance with an embodiment, a Java Virtual Machine (JVM) is associated with a management console, which allows a systems administrator to monitor current heap utilization at runtime. The heap is visualized as a contiguous chunk of memory with one or more extension points, e.g., by use of a trailing pointer to a null list. If later, at runtime, the heap size needs to be incremented then the trailing pointer can be set to a new chunk of memory with a size of (new value−old value), so that the cumulative new size is made equal to a new value specified on the console. The new chunk of memory can again end with a trailing pointer, to allow for further extension. The features can help ensure that an alert administrator will have the means to prevent an out-of-memory situation when the allocated heap proves insufficient at runtime.

COPYRIGHT NOTICE

A portion of the disclosure of this patent document contains material which is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document or the patent disclosure, as it appears in the Patent and Trademark Office patent file or records, but otherwise reserves all copyright rights whatsoever.

FIELD OF INVENTION

The invention is generally related to automatic garbage collected languages, such as Java, and is particularly related to a system and method for use with garbage collected languages and systems, for enabling the allocated heap memory to be updated at runtime, subject to sufficient availability of physical memory.

BACKGROUND

In the context of computer systems, software and languages, the software objects for a running software program are generally stored in an area of the system memory where they can be readily accessed. Some languages, such as C and C++, utilize manual memory allocation, which requires that the memory occupied by software objects be manually allocated and deallocated as needed. Other languages, such as Java and C#, utilize dynamic memory allocation, wherein a garbage collector periodically attempts to reclaim any memory occupied by software objects that are no longer in use by running programs—a process referred to as garbage collection.

In garbage collected languages, the area of memory to be garbage collected is generally referred to as the heap. Garbage collection frees the software developer from having to manually account for memory deallocation. Some computer languages that do not include garbage collection as part of their language specification do utilize it for practical or efficiency reasons (e.g., formal languages such as lambda calculus); while other computer languages (e.g., C, C++) that were originally designed to utilize manual memory management, now also provide garbage-collected implementations.

In many environments, the system includes a virtual machine upon which the software program will run. In Java, the virtual machine is referred to as a Java Virtual Machine (JVM), which allows for portability of software applications between different underlying computer architectures, including different computer hardware platforms and/or operating systems, inasmuch as the JVM allows a compiled Java program to be run on the JVM independently of whatever hardware or operating system may be used underneath. Examples of available JVMs include the Oracle JRockit and Hotspot products. Each JVM includes a garbage collector component that handles the garbage collection process for that JVM.

However, a problem with many JVM implementations is that the JVM heap generally must be sized precisely at startup; and once specified, the heap settings cannot be altered at runtime. This limitation can result in a software program at runtime using up all of the allocated memory, ultimately culminating in an out-of-memory error (e.g., OutOfMemoryError). This is the general area that embodiments of the invention are intended to address.

SUMMARY

Disclosed herein is a system and method for use with garbage collected systems and languages, for enabling an allocated heap memory to be updated (e.g., increased or decreased) at runtime, subject to sufficient availability of physical memory. In accordance with an embodiment, a Java Virtual Machine (JVM) is associated with a management console, which allows a systems administrator to monitor current heap utilization at runtime. The console also allows editing of attributes such as currently-allocated max heap attribute, max eden size, max tenured size, or max permgen space. The heap is visualized as a contiguous chunk of memory with one or more extension points, e.g., by use of a trailing pointer to a null list. If later, at runtime, the heap size needs to be incremented then the trailing pointer can be set to a new chunk of memory with a size of (new value−old value), so that the cumulative new size is made equal to a new value specified on the console. The new chunk of memory can again end with a trailing pointer, to allow for further extension. Over a period of time, the heap may include a number of such extension points, and may need to be uncluttered using an explicit defragmentation during a maintenance window which can be initiated from the console. During defragmentation, garbage collection is temporarily disabled, and all of the distributed chunks of memory can be allocated in sequence with a single null extension point per section. The features can help ensure that an alert administrator will have the means to prevent an out-of-memory situation when the allocated heap proves insufficient at runtime.

BRIEF DESCRIPTION OF THE FIGURES

FIG. 1 shows an illustration of a system for use with garbage collected languages and systems, for enabling the allocated heap memory to be increased at runtime, subject to sufficient availability of physical memory, in accordance with an embodiment.

FIG. 2 shows an illustration of how the allocated heap memory can be increased at runtime, using extension points, in accordance with an embodiment.

FIG. 3 shows an illustration of how one or more subsections of the allocated heap memory can be increased at runtime, in accordance with an embodiment.

FIG. 4 shows an illustration of how the allocated heap memory can be updated by an administrator at runtime, and subsequently defragmented, in accordance with an embodiment.

FIG. 5 shows a flowchart of a method for use with garbage collected languages and systems, for enabling the allocated heap memory to be increased at runtime, subject to sufficient availability of physical memory, in accordance with an embodiment.

DETAILED DESCRIPTION

As described above, in garbage collected languages, the area of memory generally referred to as the heap is periodically garbage collected to reclaim any memory occupied by software objects that are no longer in use by running programs. For example, a Java Virtual Machine (JVM) includes a garbage collector component that handles the garbage collection process for that JVM. However, the JVM heap generally must be sized precisely at startup; and once specified, the heap settings cannot be altered at runtime. This limitation can result in a software program at runtime using up all of the allocated memory, ultimately culminating in an out-of-memory error (e.g., OutOfMemoryError).

To address this, disclosed herein is a system and method for use with garbage collected systems and languages, for enabling an allocated heap memory to be updated (e.g., increased or decreased) at runtime, subject to sufficient availability of physical memory. As described herein, the Java language and the JVM virtual machine are included as one example of a garbage-collected language, for purposes of illustrating various embodiments of the invention. In accordance with other embodiments, the systems and methods described herein can be similarly used with other garbage-collected languages and virtual machines. In accordance with an embodiment, a JVM is associated with a management console, which allows a systems administrator to monitor current heap utilization at runtime. The console also allows editing of attributes such as currently-allocated max heap attribute, max eden size, max tenured size, or max permgen space. The heap is visualized as a contiguous chunk of memory with one or more extension points, e.g., by use of a trailing pointer to a null list. If later, at runtime, the heap size needs to be incremented then the trailing pointer can be set to a new chunk of memory with a size of (new value−old value), so that the cumulative new size is made equal to a new value specified on the console. The new chunk of memory can again end with a trailing pointer, to allow for further extension. Over a period of time, the heap may include a number of such extension points, and may need to be uncluttered using an explicit defragmentation during a maintenance window which can be initiated from the console. During defragmentation, garbage collection is temporarily disabled, and all of the distributed chunks of memory can be allocated in sequence with a single null extension point per section. The features can help ensure that an alert administrator will have the means to prevent an out-of-memory situation when the allocated heap proves insufficient at runtime.

FIG. 1 shows an illustration of a system for use with garbage collected languages and systems, for enabling the allocated heap memory to be increased at runtime, subject to sufficient availability of physical memory, in accordance with an embodiment. As shown in FIG. 1, the system 100 comprises one or more physical computers, servers, or computing devices 102. Each computer or computing device includes a set of physical resources 108, such as a processor (CPU) 110, input/output (I/O) components 112, networking resources 114, and physical memory storage 116. A virtual machine 120 (which in the context of the Java language can be, e.g., an Oracle Hotspot, JRockit, or another JVM implementation) allows compiled software programs to be run on the virtual machine, independently of the hardware or operating system used underneath. Each virtual machine also includes a compiler 122, and a garbage collector 124. An available memory 128 comprises a heap 130, for storage of compiled bytecode, typically as pages 140, and one or more extension points 142, the use of which are described in further detail below.

As further shown in FIG. 1, in accordance with an embodiment, the system allows one or more software applications or programs 132, 134 to be run thereon. Software applications can optionally run within an application server (e.g., a WebLogic instance, or a similar application server instance). The JVM is associated with a management console (i.e. a console) 150, which allows a system administrator (i.e. an administrator) 152 to display or otherwise monitor the system's current heap utilization information 154 at runtime. In accordance with an embodiment, the console also allows editing by the administrator of various heap attributes, e.g., the currently-allocated max heap, max eden size, max tenured size, or max permgen space attributes. Information about the heap utilization can be received 156 from the JVM into the console, for review by the administrator at runtime. Requests from the administrator can also be communicated 158 via the console, to the JVM.

In accordance with an embodiment, each console associated with a running JVM can be provided as a client-server mode application (similar to, e.g., jconsole) which allows monitoring current heap utilization. The console can also be configured to allow editing of attributes such as the currently allocated max heap attribute, max eden size or max tenured size or max permgen space.

FIG. 2 shows an illustration of how the allocated heap memory can be increased at runtime, using extension points, in accordance with an embodiment. As shown in FIG. 2, the heap is visualized not as a contiguous chunk of memory, but rather as a contiguous chunk of memory with one or more extension points. In accordance with an embodiment, the heap 130 stores compiled bytecode, typically as pages 140, for execution by the virtual machine. The heap comprises an initial memory chunk 150, together with one or more extension points 142. In accordance with an embodiment, the heap and its initial memory chunk can be configured to initially match a startup configuration for the JVM, as might be specified by the administrator in a configuration file. Each of the extension points can be provided as a trailing pointer 152, which initially points to null, but which can be modified later to point to a new area of memory.

As further shown in FIG. 2, at a later point in time, if the administrator determines that a larger heap size might be useful, perhaps by monitoring the heap utilization information displayed by the console and in anticipation of an out-of memory situation, the administrator can request the JVM to extend its heap, or a subsection thereof. In accordance with an embodiment, when such a request is received, an additional memory chunk 160 of appropriate size is created in memory, and the trailing pointer of the initial memory chunk modified so that it points 156 to the additional memory chunk. The additional memory chunk can include its own extension points 162, which can similarly end with a trailing pointer 172 pointing to null 174, to allow for further extension in a chaining manner. In this manner, the heap 130 can be successively extended, as illustrated in FIG. 2 by the shaded area, to address the request from the console.

As further shown in FIG. 2, at a yet later point in time, if the administrator determines that a yet larger heap size might be useful, the administrator can again use the console to request the JVM to further extend its heap, or a subsection thereof. As before, when the request is received, an additional memory chunk 180 is created in memory, and the trailing pointer of the last memory chunk modified so that it points 176 to the additional memory chunk. The additional memory chunk can again include its own extension points 182, similarly ending with a trailing pointer 192 pointing to null 194, to allow for further extension, subject to available memory 128.

By way of example, suppose that the JVM heap attributes initially indicate that: Xms=Xmx=1 GB and that the administrator is allowed to set values for heap size using the console. Then, in this example, the heap size can be initially allocated as 1 GB, but with a trailing pointer to a null list. If later, it is determined that the heap size needs to be incremented, then, in response to a request from the administrator this trailing pointer can be set to a new chunk of memory with a size equal to (new value−old value). Hence the cumulative new heap size becomes equal to the new value specified on the console, which is calculated as: new value=old value+(new value−old value)

As described above, the new chunk of memory again needs to end with a trailing pointer to account for any further extension in future. In accordance with an embodiment, if the total available physical memory is less than the new value specified, then the operation will be disallowed.

FIG. 3 shows an illustration of how one or more subsections of the allocated heap memory can be increased at runtime, in accordance with an embodiment. As shown in FIG. 3, in addition to extending the heap as a whole, the administrator can alternatively elect to extend particular subsections of the heap. For example, as shown in FIG. 3, the heap can include subsections such as eden spaces 200, tenured space 210, and permgen space 230, that can be extended independently. In accordance with other embodiments and implementations, the memory/heap space can be configured differently from the one illustrated.

As shown in FIG. 3, each subsection can be associated with its own initial memory chunk space 202, 212, 232, which using the above described techniques can include extension points 204, 214, 215, 232, that allow additional memory chunks 206, 216, 217, 218, 222 to be added as desired by the administrator. As illustrated in the example of FIG. 3, in accordance with an embodiment, some spaces can have multiple extension points, e.g., tenured space 210 is illustrated with two extension points, each of which allows additional memory chunks to be extended. Other memory subsections can utilize a single extension point that can be increased by successively chaining trailing pointers as described above. In this manner, the technique can be applied at an individual subsection level as well, e.g., by modifying the max eden size, or max tenured size or max perm size, each of which can be extended at runtime using extension points.

FIG. 4 shows an illustration of how the allocated heap memory can be updated by an administrator at runtime, and subsequently defragmented, in accordance with an embodiment. Over a period of time the heap may include a number of extension points, and may need to be uncluttered using an explicit defragmentation during a maintenance window which can be initiated from the console. As shown in FIG. 4, the heap may include an initial memory chunk 240. Through feedback of heap utilization information 242, and receipt of administrator requests 244, the heap may be extended with one or more additional memory chunks 246, 248. In accordance with an embodiment, during defragmentation all of the distributed chunks of memory can be allocated in sequence 260, including the objects therein 262, 264, with a single null extension point per section. The garbage collector and/or garbage collection process 124 will be temporarily disabled until this activity is completed. The remaining free space 270 in the heap can be subsequently used for heap purposes, or, in accordance with an embodiment, can be recaptured 272 for use by the virtual machine, (including decreasing/shrinking the heap size or its subsections where appropriate).

In accordance with an embodiment, a request from the administrator to decrease the heap size can be used by the system to initiate a defragmentation cycle. If, after defragmentation, the used memory is greater than that specified by the administrator using the console, then the current heap size will be retained and the administrator notified accordingly. This prevents the system from discarding portions of the heap currently in use, even if requested to do so (perhaps inadvertently) by the administrator.

FIG. 5 shows a flowchart of a method for use with garbage collected languages and systems, for enabling the allocated heap memory to be increased at runtime, subject to sufficient availability of physical memory, in accordance with an embodiment. As shown in FIG. 5, in step 280, the virtual machine heap is initiated with heap attributes (including heap subsection attributes where appropriate) as an initial memory chunk having one or more extension points, such as null pointers. In step 282, at runtime, the administration console receives information from the virtual machine describing its current heap utilization, for review by the system administrator. In step 284, the administrator uses the administration console to request the virtual machine to update (e.g. increase or decrease) the size of the heap (or the size of one or more heap subsections), subject to sufficient availability of physical memory. In step 286, if the request is one to increase the size of the heap, then extension points are used, e.g., by modifying null pointers to point to additional memory chunks, to increase the size of the heap or heap subsections, in response to the administrator's request.

In accordance with an embodiment, the above-described features help ensure that an alert administrator will have the means to prevent an out-of-memory (e.g., OutOfMemoryError) situation when the allocated heap proves insufficient at runtime, rather than having to helplessly await an application crash. Given that memory overflow accounts for a large number of reported problems for automatic garbage collected platforms, the above provides a workaround for such situations.

The present invention may be conveniently implemented using one or more conventional general purpose or specialized digital computer, computing device, machine, or microprocessor, including one or more processors, memory and/or computer readable storage media programmed according to the teachings of the present disclosure. Appropriate software coding can readily be prepared by skilled programmers based on the teachings of the present disclosure, as will be apparent to those skilled in the software art.

In some embodiments, the present invention includes a computer program product which is a non-transitory storage medium or computer readable medium (media) having instructions stored thereon/in which can be used to program a computer to perform any of the processes of the present invention. The storage medium can include, but is not limited to, any type of disk including floppy disks, optical discs, DVD, CD-ROMs, microdrive, and magneto-optical disks, ROMs, RAMs, EPROMs, EEPROMs, DRAMs, VRAMs, flash memory devices, magnetic or optical cards, nanosystems (including molecular memory ICs), or any type of media or device suitable for storing instructions and/or data.

The foregoing description of the present invention has been provided for the purposes of illustration and description. It is not intended to be exhaustive or to limit the invention to the precise forms disclosed. Many modifications and variations will be apparent to the practitioner skilled in the art. Particularly, as described above, the Java language and the JVM virtual machine are included as one example of a garbage-collected language, for purposes of illustrating various embodiments of the invention. In accordance with other embodiments, the systems and methods described herein can be similarly used with other garbage-collected languages and virtual machines. The embodiments were chosen and described in order to best explain the principles of the invention and its practical application, thereby enabling others skilled in the art to understand the invention for various embodiments and with various modifications that are suited to the particular use contemplated. It is intended that the scope of the invention be defined by the following claims and their equivalence. 

What is claimed is:
 1. A computer system for use with garbage collected languages and systems, for enabling an allocated heap memory to be updated at runtime, subject to sufficient availability of physical memory, comprising: a computing device which includes a processor, a virtual machine, and a heap for storage of compiled bytecode, and that enables one or more software applications to be run thereon, wherein the heap includes an initial memory chunk and one or more extension points, wherein each extension point includes a trailing pointer that initially points to null, and that can be modified in response to receiving a request to increase the size of the heap or a subsection thereof, to point to an additional memory chunk and increase the size of the heap or subsection accordingly; wherein information about the heap's current utilization can be communicated to a console; and wherein, in response to receiving a request to increase the size of the heap or a subsection thereof, the heap or subsection is successively extended using the extension points, including successively modifying the trailing pointer of each of a plurality of extension points, to add one or more additional memory chunks and increase the size of the heap or subsection accordingly, and wherein, in response to receiving a subsequent request to decrease the size of the heap or the subsection thereof, the size of the heap or subsection is decreased accordingly.
 2. The system of claim 1, further comprising a console for use by an administrator in displaying or monitoring the heap's current utilization, and issuing requests to increase the size of the heap or a subsection thereof, wherein the administrator can indicate a new value for the size of the heap or a subsection thereof, and wherein the system then increases the size of the heap or the subsection accordingly.
 3. The system of claim 1, wherein each of a plurality of subsections of the heap includes its own one or more extension point, to allow that particular subsection to be extended and increased in size.
 4. The system of claim 1, wherein in response to receiving the subsequent request to decrease the size of the heap or a subsection thereof, the heap is defragmented including that one or more of the additional memory chunks are allocated in sequence including the objects therein, and the previously occupied memory recaptured for use by the virtual machine.
 5. The system of claim 1, wherein garbage collected language is Java, and the virtual machine is a Java Virtual Machine (JVM).
 6. A computer-implemented method for use with garbage collected languages and systems, for enabling an allocated heap memory to be updated at runtime, subject to sufficient availability of physical memory, comprising the steps of: providing at a computing device which includes a processor and a virtual machine, a heap for storage of compiled bytecode, and that enables one or more software applications to be run thereon, wherein the heap includes an initial memory chunk and one or more extension points, wherein each extension point includes a trailing pointer that initially points to null, and that can be modified in response to receiving a request to increase the size of the heap or a subsection thereof, to point to an additional memory chunk and increase the size of the heap or subsection accordingly; communicating information about the heap's current utilization to a console; and in response to receiving a request to increase the size of the heap or a subsection thereof, successively extending the heap or subsection using the extension points, including successively modifying the trailing pointer of each of a plurality of extension points, to add one or more additional memory chunks and increase the size of the heap or subsection accordingly, and wherein, in response to receiving a subsequent request to decrease the size of the heap or the subsection thereof, the size of the heap or subsection is decreased accordingly.
 7. The method of claim 6, further comprising providing a console for use by an administrator in displaying or monitoring the heap's current utilization, and issuing requests to increase the size of the heap or a subsection thereof, wherein the administrator can indicate a new value for the size of the heap or a subsection thereof, and wherein the system then increases the size of the heap or the subsection accordingly.
 8. The method of claim 6, wherein each of a plurality of subsections of the heap includes its own one or more extension point, to allow that particular subsection to be extended and increased in size.
 9. The method of claim 6, wherein in response to receiving the subsequent request to decrease the size of the heap or a subsection thereof, the heap is defragmented including that one or more of the additional memory chunks are allocated in sequence including the objects therein, and the previously occupied memory recaptured for use by the virtual machine.
 10. The method of claim 6, wherein garbage collected language is Java, and the virtual machine is a Java Virtual Machine (JVM).
 11. A non-transitory computer readable storage medium, including instructions stored thereon, which when read and executed by a computer, cause the computer to perform the steps comprising: providing at a computing device which includes a processor and a virtual machine, a heap for storage of compiled bytecode, and that enables one or more software applications to be run thereon, wherein the heap includes an initial memory chunk and one or more extension points, wherein each extension point includes a trailing pointer that can be modified in response to receiving a request to increase the size of the heap or a subsection thereof, to point to an additional memory chunk and increase the size of the heap or subsection accordingly; communicating information about the heap's current utilization to a console; and in response to receiving a request to increase the size of the heap or a subsection thereof, successively extending the heap or subsection using the extension points, including successively modifying the trailing pointer of each of a plurality of extension points, to add one or more additional memory chunks and increase the size of the heap or subsection accordingly, and wherein, in response to receiving a subsequent request to decrease the size of the heap or the subsection thereof, the size of the heap or subsection is decreased accordingly.
 12. The non-transitory computer readable storage medium of claim 11, further comprising providing a console for use by an administrator in displaying or monitoring the heap's current utilization, and issuing requests to increase the size of the heap or a subsection thereof, wherein the administrator can indicate a new value for the size of the heap or a subsection thereof, and wherein the system then increases the size of the heap or the subsection accordingly.
 13. The non-transitory computer readable storage medium of claim 11, wherein each of a plurality of subsections of the heap includes its own one or more extension point, to allow that particular subsection to be extended and increased in size.
 14. The non-transitory computer readable storage medium of claim 11, wherein in response to receiving the subsequent request to decrease the size of the heap or a subsection thereof, the heap is defragmented including that one or more of the additional memory chunks are allocated in sequence including the objects therein, and the previously occupied memory recaptured for use by the virtual machine.
 15. The non-transitory computer readable storage medium of claim 11, wherein garbage collected language is Java, and the virtual machine is a Java Virtual Machine (JVM). 